<template>
    <div>
        <zh-row>
            <zh-col :span="8">
              <FileClassTree ref="classTreeRef" @nodeClick="getClassInfo" >
              </FileClassTree>
            </zh-col>

            <zh-col :span="16">
              <zh-card title="授权信息">
                <zh-form ref="formRef" :md="24" :lg="24" :xl="24"  :model="appClassInfo" :rules="rules" labelWidth="120">
                    <zh-form-select
                        prop="appId"
                        :lazy="true"
                        label="所属应用"
                        v-model="appClassInfo.appId"
                        :fieldNames="{ label: 'appName', value: 'appId' }"
                        funcCode="application0012"
                        :disabled="props.displayFlag"
                        searchField="appName"
                    ></zh-form-select>
                    <zh-form-input prop="fileClassCode" label="文件分类编码"  v-model="appClassInfo.fileClassCode" v-if="false"
                                disabled></zh-form-input>
                    <zh-form-input prop="fileClassTitle" label="文件分类"  v-model="appClassInfo.fileClassTitle" v-if="false"
                                disabled></zh-form-input>
                    <zh-form-input prop="fileClassPath" label="存放基础路径"  v-model="appClassInfo.fileClassPath"
                                :disabled="props.displayFlag"></zh-form-input>
                
                    <zh-form-date
                            prop="expireTime"
                            label="到期时间"
                            placeholder="请输入到期时间"
                            type="datetime"
                            v-model="appClassInfo.expireTime"
                        ></zh-form-date>
                </zh-form>
             </zh-card>
            </zh-col>
        </zh-row>
  </div>
</template>

<script lang="ts" setup name="appClassInfo">
// import {FormInstance} from "element-plus";
import ZhForm from "@/components/zh-form/index.vue";
import FileClassTree from '@/views/fileCenter/fileApply/component/FileClassTree.vue';

// ------------------变量区------------------------------
const props = defineProps({
  scrollHeight: {
    type: String,
    default: ''
  },
  displayFlag: {
    type: Boolean,
    default:false
  },
});
const formRef = ref<any>();
const appClassInfo = ref<any>({
});
const classTreeRef=ref();

const rules = reactive({
  appId: [
    {
      required: true,
      message: '请选择需要授权的应用',
      trigger: 'blur',
    },
  ],
  fileClassCode: [
    {
      required: true,
      message: '请选择需要授权的文件分类',
      trigger: 'blur',
    },
  ],
  expireTime: [
    {
      required: true,
      message: '请选择过期时间',
      trigger: 'blur',
    },
  ]
});



//------------------初始化------------------------------


//--------------------------定义调用方法--------------------------------------------------
function setInitData(info) {
//   formRef.value?.resetFields();
//   if (info) {
//     appClassInfo.value=info;
//   }
}

function getClassInfo(){
  //获取当前树选中的节点
  appClassInfo.value.fileClassCode=classTreeRef.value.selectNode.key;
  appClassInfo.value.fileClassTitle=classTreeRef.value.selectNode.title;
}

function getCheckedKeys(){
  // console.log("aaa")
  return classTreeRef.value.getCheckedKeys();
}

//------------设置给父组件调用的数据/方法(组件)-----------
defineExpose({setInitData,appClassInfo,getCheckedKeys});
</script>
